$(function () {
    var $userTableForm = $(".user-table-form");
    var settings = {
        url: ctx + "cardInfo/list",
        pageSize: 10,
        queryParams: function (params) {
            return {
                pageSize: params.limit,
                pageNum: params.offset / params.limit + 1,
                paperId: $userTableForm.find("input[name='paperId']").val().trim(),
                cardNo: $userTableForm.find("input[name='cardNo']").val().trim(),
                cardUserName: $userTableForm.find("input[name='cardUserName']").val().trim()
            };
        },
        columns: [{
            field: 'paperId',
            title: '证件号'
        }, {
            field: 'cardNo',
            title: '卡号'
        }, {
            field: 'cardUserName',
            title: '持卡人姓名'
        }, {
            field: 'cardBanlance',
            title: '系统卡内余额'
        },{
            field: 'accBanlance',
            title: '实名账户余额'
        }, {
            field: 'cardStateName',
            title: '卡状态'
        },{
            field: 'cardTypeName',
            title: '卡类型'
        },{
            title : '操作',
            field : 'id',
            align : 'center',
            width :  120 ,
            valign : 'middle',
            formatter : function(value,row,index){
                var e = '<button type="button" class="btn btn-primary" id="card_reading" data-toggle="modal" data-target="#myModal" onclick="showImg(\''+ row.cardNo + '\')">查看实名信息</button> ';
                var d = '<button type="button" class="btn btn-primary" id="card_reading" data-toggle="modal" data-target="#noCard" shiro:hasAnyPermissions="cardInfo:withdraw" onclick="notCard(\''+ row.cardNo + '\')">无卡退卡</button> ';
                return e+d;
            }
        }]
    };
    $MB.initTable('userTable', settings);
});

function showImg(r) {
    $("#myModal").find("#paperPhoto").attr("src","http://120.77.182.149:8080/photos/" + r.substring(8,16) + ".jpg");
}

function notCard(r) {
    $("#noCard").find("#not-card-paperPhoto").attr("src","http://120.77.182.149:8080/photos/" + r.substring(8,16) + ".jpg");
    load_data(r);
}

function search() {
    $MB.refreshTable('userTable');
}

